package com.emellend.api.gallery;

import com.emellend.api.R;
import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.ContactsContract.Contacts;
import android.widget.Gallery;
import android.widget.SimpleCursorAdapter;
import android.widget.SpinnerAdapter;

public class Gallery2 extends Activity{
	private static final String[] CONTACT_PROJECTION = new String[] {
        Contacts._ID,
        Contacts.DISPLAY_NAME
    };
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.gallery_2);
		init();
	}

	private void init() {
		Cursor cursor = getContentResolver().query(Contacts.CONTENT_URI, CONTACT_PROJECTION, 
				null, null, null);
		startManagingCursor(cursor);
		SpinnerAdapter adapter=new SimpleCursorAdapter(this, 
				android.R.layout.simple_gallery_item, cursor, 
				new String[]{Contacts.DISPLAY_NAME}, 
				new int[]{android.R.id.text1});
		Gallery gallery = (Gallery) findViewById(R.id.gallery);
		gallery.setAdapter(adapter);
	}
}
